﻿using Microsoft.AspNetCore.Mvc;
using NFine.Data.Dto.WeixinManage;
using NFine.Service.WeixinManage;
using NFine.Util;
using NFine.Web.Controllers;

namespace NFine.Web.Areas.WeiXinManage.Controllers
{
    [Area("WeiXinManage")]
    public class WxUserController : NFineController
    {
        WxUserService wxUserService = new WxUserService();
        //protected readonly Rabbit.WeiXin.MP.Api.ICommonService CommonService;

        public IActionResult Index()
        {
            //OperatorModel operatorModel = OperatorProvider.Provider.GetOperator();
            //operatorModel.AccountModel = new Rabbit.WeiXin.MP.Api.AccountModel
            //{
            //    AppId = operatorModel.WxAccountModel.AppId,
            //    AppSecret = operatorModel.WxAccountModel.AppSecret,
            //    GetAccessToken = CommonService.GetAccessToken()
            //};

            return View();
        }
        [HttpGet]
        public ActionResult GetGridJson(Pagination pagination, string keyword)
        {
            var data = new
            {
                rows = wxUserService.GetList(pagination, keyword),
                total = pagination.total,
                page = pagination.page,
                records = pagination.records
            };
            return Content(data.ToJson());
        }

        //[HttpGet]
        //public ActionResult GetFormJson(string keyValue)
        //{
        //    var data = wxUserService.GetForm(keyValue);
        //    return Content(data.ToJson());
        //}

        //[HttpPost]
        //public ActionResult SubmitForm(WxAccountInputDto wxAccountInputDto, string keyValue)
        //{
        //    wxAccountService.SubmitForm(wxAccountInputDto, keyValue);
        //    return Success("操作成功。");
        //}

        //[HttpPost]
        //public ActionResult DeleteForm(string keyValue)
        //{
        //    wxAccountService.DeleteForm(keyValue);
        //    return Success("操作成功。");
        //}

        [HttpGet]
        public IActionResult SyncUserInfo()
        {
            wxUserService.SyncUserInfo();
            return Success("操作成功。");
        }
    }
}